package controllers;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;
import java.util.GregorianCalendar;


public class Utile {
	
	public static Date stringToDate(String d) throws ParseException{
		DateFormat sdf =  new SimpleDateFormat("dd/MM/yyyy HH:mm");
		Date date = sdf.parse(d);
		return date;
	}
	
	public static String dateToString(GregorianCalendar gc) throws ParseException{
		DateFormat sdf =  new SimpleDateFormat("dd/MM/yyyy HH:mm");
		Date date= gc.getTime();
		String retourn=sdf.format(date);
		return retourn;
	}
	public static String generateCle(){
		String chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
		//String nums = "1234567890";
		int charLength = chars.length();//+nums.length();
	    StringBuilder pass = new StringBuilder(charLength);
			for (int x = 0; x < 10; x++) {
				int i = (int) (Math.random() * charLength);
				//if(x==3 || x==7 || x==8){
				//	pass.append(nums.charAt(i));
				//}else 
				pass.append(chars.charAt(i));
			}
			return pass.toString();
	}


}
